import * as Cesium from 'cesium/Cesium'
function AxisLinePrimitive(e) {
    this.show = Cesium.defaultValue(e.show, !0),
        this.id = e.id;
    var t = e.positions;
    e.loop && (t = t.slice()).push(t[0]);
    var i = Cesium.defaultValue(e.arrow, !1);
    this._width = Cesium.defined(e.width) ? e.width : i ? 25 : 8,
        this._color = e.color,
        this._depthFailColor = e.color.withAlpha(.3),
        this._positions = t,
        this._arrow = i,
        this._depthFail = Cesium.defaultValue(e.depthFail, !0),
        this._primitive = void 0,
        this._boundingSphere = Cesium.BoundingSphere.fromPoints(t),
        this._transformedBoundingSphere = Cesium.BoundingSphere.clone(this._boundingSphere),
        this._modelMatrix = Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY),
        this._update = !0
}

Cesium.defineProperties(AxisLinePrimitive.prototype, {
    modelMatrix: {
        get: function() {
            return this._modelMatrix
        },
        set: function(e) {
            Cesium.Matrix4.equalsEpsilon(e, this._modelMatrix, Cesium.Math.EPSILON10) || (this._modelMatrix = Cesium.Matrix4.clone(e, this._modelMatrix),
                this._update = !0)
        }
    },
    positions: {
        get: function() {
            return this._positions
        },
        set: function(e) {
            this._positions = e,
                this._update = !0
        }
    },
    color: {
        get: function() {
            return this._color
        }
    },
    width: {
        get: function() {
            return this._width
        }
    },
    boundingVolume: {
        get: function() {
            return this._transformedBoundingSphere
        }
    }
}),
    AxisLinePrimitive.prototype.update = function(e) {
        if (this.show) {
            if (this._update) {
                this._update = !1,
                    this._primitive = this._primitive && this._primitive.destroy();
                var t, i, r = new Cesium.PolylineGeometry({
                    positions: this._positions,
                    width: this._width,
                    vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT,
                    arcType: Cesium.ArcType.NONE
                });
                this._arrow ? (t = new Cesium.PolylineMaterialAppearance({
                    material: Cesium.Material.fromType(Cesium.Material.PolylineArrowType, {
                        color: this._color
                    })
                }),
                this._depthFail && (i = new Cesium.PolylineMaterialAppearance({
                    material: Cesium.Material.fromType(Cesium.Material.PolylineArrowType, {
                        color: this._depthFailColor
                    })
                }))) : (t = new Cesium.PolylineColorAppearance({
                    translucent: 1 !== this._color.alpha
                }),
                this._depthFail && (i = new Cesium.PolylineColorAppearance({
                    translucent: 1 !== this._depthFailColor.alpha
                })));
                var n = this._modelMatrix;
                this._primitive = new Cesium.Primitive({
                    geometryInstances: new Cesium.GeometryInstance({
                        geometry: r,
                        attributes: {
                            color: Cesium.ColorGeometryInstanceAttribute.fromColor(this._color),
                            depthFailColor: Cesium.ColorGeometryInstanceAttribute.fromColor(this._depthFailColor)
                        },
                        id: this.id,
                        modelMatrix: n
                    }),
                    appearance: t,
                    depthFailAppearance: i,
                    asynchronous: !1
                }),
                    this._transformedBoundingSphere = Cesium.BoundingSphere.transform(this._boundingSphere, n, this._transformedBoundingSphere)
            }
            this._primitive.update(e)
        }
    }
    ,
    AxisLinePrimitive.prototype.isDestroyed = function() {
        return !1
    }
    ,
    AxisLinePrimitive.prototype.destroy = function() {
        return this._primitive = this._primitive && this._primitive.destroy(),
            Cesium.destroyObject(this)
    }
;
export default AxisLinePrimitive;